package com.projects.xenia.journals_activities;

import java.text.SimpleDateFormat;

import android.app.Activity;
import android.content.Intent;

import android.widget.Toast;

import com.projects.xenia.R;
import com.projects.xenia.documents_activities.Activity_Task;
import com.projects.xenia.documents_classes.Documents_Task;
import com.projects.xenia.documents_classes.Documents_Visit;
import com.projects.xenia.global_modules.MainGlobalModule;

public class Activity_Journal_Tasks extends JournalActivity {

	@Override
	public void GetJournalCursor() {

		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");		
		String ReturnJournalStartDateValueString = sdf.format(JournalStartDateValue);
		String ReturnJournalStopDateValueString = sdf.format(JournalStopDateValue);
			
		JournalCursor = MainGlobalModule.DBE.rawQuery("select a.id,a.docnum,date(a.date_create) as date_create ,a.state,a.customers_id,0 as total_sum ,b.descr,b.outletdescr,b.outletadress from xdoc_tasks_h a left outer join xref_customers b on a.customers_id = b.id where date(a.date_create) between date(?) and date(?) order by date(a.date_create),a.docnum", new String []{ReturnJournalStartDateValueString,ReturnJournalStopDateValueString});		
		
	}

	@Override
	public void SetIconAndDescr() {
		
		head_ico.setImageResource(R.drawable.st_tasks);
		head_text.setText("Задания");
		
	}

	@Override
	public void StartDocumentsDetailsJournalActivity() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void CreateOpenDocument() {

    	Intent DocumentActivity = new Intent ();    	
    	DocumentActivity.setClass(Ctx, Activity_Task.class);
    	DocumentActivity.putExtra("CustomerId", Journ_Customer.getTag()==null?null:String.valueOf(Journ_Customer.getTag()));    	
    	((Activity)Ctx).startActivityForResult(DocumentActivity, 0); 
		
	}

	@Override
	public void OpenDocument() {
		
		Intent DocumentActivity = new Intent ();    	
    	DocumentActivity.setClass(Ctx, Activity_Task.class);
    	DocumentActivity.putExtra("DocId", id);    	
    	((Activity)Ctx).startActivityForResult(DocumentActivity, 0);
		
	}

	@Override
	public void DeleteDocument() {
		
		Documents_Task Doc = new Documents_Task();
		Doc.OpenDoc(id);
		Doc.DeleteDoc ();
		RefreshList();
		
	}

	@Override
	public void JournIcoEvents() {
		// TODO Auto-generated method stub
		
	}
	

}
